// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   IpFilterConfig.java

package org.quickserver.util.xmlreader;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

public class IpFilterConfig
    implements Serializable
{

    public IpFilterConfig()
    {
        ipCollection = null;
        enable = false;
        allowAccess = false;
        ipCollection = new ArrayList();
    }

    public void addClientIpAddress(String clientIpAddress)
    {
        if(clientIpAddress != null)
            ipCollection.add(clientIpAddress);
    }

    public ArrayList getIpCollection()
    {
        return ipCollection;
    }

    public Iterator iterator()
    {
        return ipCollection.iterator();
    }

    public void setEnable(boolean enable)
    {
        this.enable = enable;
    }

    public boolean getEnable()
    {
        return enable;
    }

    public void setAllowAccess(boolean enable)
    {
        allowAccess = enable;
    }

    public boolean getAllowAccess()
    {
        return allowAccess;
    }

    public String toXML(String pad)
    {
        if(pad == null)
            pad = "";
        StringBuilder sb = new StringBuilder();
        sb.append(pad).append("<ip-filter>\n");
        sb.append(pad).append("\t<enable>").append(getEnable()).append("</enable>\n");
        sb.append(pad).append("\t<allow-access>").append(getAllowAccess()).append("</allow-access>\n");
        sb.append(pad).append("\t<ip-collection>\n");
        String cip;
        for(Iterator iterator = iterator(); iterator.hasNext(); sb.append(pad).append("\t\t<client-ip-address>").append(cip).append("</client-ip-address>\n"))
            cip = (String)iterator.next();

        sb.append(pad).append("\t</ip-collection>\n");
        sb.append(pad).append("</ip-filter>\n");
        return sb.toString();
    }

    private ArrayList ipCollection;
    private boolean enable;
    private boolean allowAccess;
}
